Skip to main content

Getting Started

Quick guide to integrate ChainSafe Storage with your platform.

Create an API Key

API key is a secret code used to identify and authenticate an application. It’s a long lived token mainly used for service - service interaction. Create an API Key using the storage dashboard

image

Create a bucket

A bucket is a container for objects. You can create folders and store objects in the bucket. Use the below API to create the bucket.

curl --request POST 'https://api.chainsafe.io/api/v1/buckets' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "fps",
"name": "<<bucket_name>>",
}'

Response:

{
"id": "string",
"name": "string",
"type": "csf",
"owners": [
{
"uuid": "string",
"encryption_key": "string"
}
],
"writers": [
{
"uuid": "string",
"encryption_key": "string"
}
],
"readers": [
{
"uuid": "string",
"encryption_key": "string"
}
],
"size": 0,
"public": "read",
"file_system_type": "chainsafe",
"status": "created"
}

Note:

save the bucket id for performing other operations replace the <<bucket_name>> with the name of your bucket

Uploading the file

Use the below API to upload files to the bucket.

The API accepts form parameters:

file - list of files to upload

path - the path inside bucket where files should be uploaded

curl --location --request POST 'https://api.chainsafe.io/api/v1/bucket/<<bucket_id>>/upload' \
--header 'Authorization: Bearer <<api_key>>' \
--form 'file=@"/Desktop/image.png"' \
--form 'path="/"'

Download the file using storage API

Use the following API to download the file using storage API through API key

curl --location --request POST 'https://api.chainsafe.io/api/v1/bucket/<<bucket_id>>/download' \
--header 'Authorization: Bearer <<api_key>>' \
--header 'Content-Type: application/json' \
--data-raw '{
"path": "/image.png"
}'

Note:

replace the file path with the path of your file replace the <<bucket_id>> with the name of your bucket replace the <<api_key>> with the api key you created

Download the file using gateway

curl https://ipfs.chainsafe.io/ipfs/{cid}

Note:

replace the {cid} with the cid of your file

You can explore more about the various APIs in our API documentation